const fish_dict = require('./index')
const os = require('os')
const utils = require('./lib/utils')
const path = require('path')
const debug = require('./lib/debug/debug')

const test_options = {
    make: 'make',
    read: 'read',
    debug: 'debug',
}

const test_which = test_options.make

async function go() {
    switch (test_which) {
        case test_options.make:
            const dst = await fish_dict.make_dict(path.join(__dirname, '../dict_doc_guoyucidian'))
            // const dst = await fish_dict.make_dict(path.join(__dirname, '../dict_doc_hanyudacidian'))
            // const dst = await fish_dict.make_dict(path.join(__dirname, '../dict_doc_shuowenjiezi'))
            console.log('..dst', dst)
            break;

        case test_options.read:
            const dict = fish_dict.read_dict(path.join(utils.getCacheDir(), 'make_dict_cache'))
            const one = dict.findInWord('一')
            console.log('一, result', JSON.stringify(one))

            const two = dict.findInWord('1', { readContent: true })
            console.log('1 ret', JSON.stringify(two))

            const three = dict.findInWord(/二/g, { readContent: true })
            console.log('二 ret', JSON.stringify(three))
            break;

        case test_options.debug:
            debug('../dict_doc_shuowenjiezi')
            break;
    }
}

go();